﻿using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
using SellAndBuy.Domain.Entities;

namespace SellAndBuy.Infrastructure.Data.Mappings
{
    public class CustomerMap : ClassMapping<Customer>
    {
        public CustomerMap()
        {
            Lazy(false);
            Id(x => x.ID, map => map.Generator(Generators.HighLow, gmap => gmap.Params(new {max_low = 100})));
            Property(x => x.FirstName, map => map.NotNullable(true));
            Property(x => x.LastName, map => map.NotNullable(true));
            Property(x => x.Email, map =>
                                       {
                                           map.Unique(true);
                                           map.Length(50);
                                           map.NotNullable(true);
                                       });
            //Set(x => x.Ads,
            //    collectionMapping =>
            //    {
            //        collectionMapping.Cascade(Cascade.All);
            //        //collectionMapping.Inverse(true);
            //        collectionMapping.Lazy(CollectionLazy.Lazy);
            //    },
            //    mapping =>
            //    {
            //        mapping.OneToMany(m =>
            //                              {
            //                                  m.Class(typeof(Ad));
            //                              }
            //            );
            //    });
        }
    }
}